package com.leetcode.algorithm.y22.m09.w2;

/**
 * 1903. 字符串中的最大奇数
 * 
 * https://leetcode.cn/problems/largest-odd-number-in-string/
 * 
 * @author jie.deng
 *
 */
class Question1903Solution01 {
	
	public String largestOddNumber(String num) {
		int len = num.length();
		int idx = len - 1;
		while (idx >= 0) {
			if ((num.charAt(idx) - '0' & 1) == 1) {
				break;
			}
			idx--;
		}
		if (idx == -1) {
			return "";
		}
		return num.substring(0, idx + 1);
	}
    
}